package com.csx.orm.mybatis.diy.controller;

import com.csx.orm.mybatis.diy.entity.UserDIYEntity;
import com.csx.orm.mybatis.diy.service.UserDIYService;
import com.csx.orm.mybatis.entity.User;
import com.csx.orm.mybatis.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequestMapping("/mybatis/diy")
@RestController
public class UserDIYController {

    @Autowired
    private UserDIYService userDIYService;

    @GetMapping("/findAll")
    public List<UserDIYEntity> findAll() {
        return userDIYService.findAll();
    }

    @PostMapping("/insert")
    public void insert(@RequestBody UserDIYEntity entity) {
        userDIYService.insert(entity);
    }

    @PostMapping("/update")
    public void update(@RequestBody UserDIYEntity entity) {
        userDIYService.update(entity);
    }

    @GetMapping("/get")
    public UserDIYEntity get(@RequestParam("id") Long id) {
        return userDIYService.get(id);
    }

}
